﻿/// <reference path="intellisense/jquery-1.2.6-vsdoc.js" />
try { document.execCommand("BackgroundImageCache", false, true); } catch (e) { }
var popUpWin;
function PopUpCenterWindow(URLStr, width, height, newWin, scrollbars) {
    var popUpWin = 0;
    if (typeof (newWin) == "undefined") {
        newWin = false;
    }
    if (typeof (scrollbars) == "undefined") {
        scrollbars = 0;
    }
    if (typeof (width) == "undefined") {
        width = 800;
    }
    if (typeof (height) == "undefined") {
        height = 600;
    }
    var left = 0;
    var top = 0;
    if (screen.width >= width) {
        left = Math.floor((screen.width - width) / 2);
    }
    if (screen.height >= height) {
        top = Math.floor((screen.height - height) / 2);
    }
    if (newWin) {
        open(URLStr, '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbars + ',resizable=yes,copyhistory=yes,width=' + width + ',height=' + height + ',left=' + left + ', top=' + top + ',screenX=' + left + ',screenY=' + top + '');
        return;
    }

    if (popUpWin) {
        if (!popUpWin.closed) popUpWin.close();
    }
    popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbars + ',resizable=yes,copyhistory=yes,width=' + width + ',height=' + height + ',left=' + left + ', top=' + top + ',screenX=' + left + ',screenY=' + top + '');
    popUpWin.focus();
}

function OpenModelWindow(url, option) {
    var tmp$;
    try {
        if (parent != null && parent.$ != null && parent.$.ShowIfrmDailog != undefined) {
            tmp$ = parent.$;
        }
        else {
            tmp$ = $;
        }
    }
    catch (e) {
        tmp$ = $;
    }
    tmp$.ShowIfrmDailog(url, option);
}
function CloseModelWindow(win, callback, dooptioncallback) {
    win.frameElement.closeIfrm(callback, dooptioncallback);
}

function StrFormat(temp, dataarry) {
    return temp.replace(/\{([\d]+)\}/g, function(s1, s2) { var s = dataarry[s2]; if (typeof (s) != "undefined") { if (s instanceof (Date)) { return s.getTimezoneOffset() } else { return encodeURIComponent(s) } } else { return "" } });
}
function StrFormatNoEncode(temp, dataarry) {
    return temp.replace(/\{([\d]+)\}/g, function(s1, s2) { var s = dataarry[s2]; if (typeof (s) != "undefined") { if (s instanceof (Date)) { return s.getTimezoneOffset() } else { return (s); } } else { return ""; } });
}
function getiev() {
    var userAgent = window.navigator.userAgent.toLowerCase();
    $.browser.msie8 = $.browser.msie && /msie 8\.0/i.test(userAgent);
    $.browser.msie7 = $.browser.msie && /msie 7\.0/i.test(userAgent);
    $.browser.msie6 = !$.browser.msie8 && !$.browser.msie7 && $.browser.msie && /msie 6\.0/i.test(userAgent);
    var v;
    if ($.browser.msie8) {
        v = 8;
    }
    else if ($.browser.msie7) {
        v = 7;
    }
    else if ($.browser.msie6) {
        v = 6;
    }
    else { v = -1; }
    return v;
}
$(document).ready(function() {
    var v = getiev()
    if (v > 0) {
        $(document.body).addClass("ie ie" + v);
    }

});

//
//xxxx年xx月xx日(曜日)に変更
//
function FormatDate(date) {
    var Year = 0;
    var Month = 0;
    var Day = 0;
    var week = "";
    var date = new Date(date.replace("-", "/"));
    var strDate = "";
    Year = date.getFullYear();
    Month = date.getMonth()+1;
    Day = date.getDate();
    strDate = Year + "年";
    if (Month >= 10) {
        strDate += Month + "月";
    } else {
        strDate += "0" + Month + "月";
    }
    if (Day >= 10) {
        strDate += Day + "日";
    } else {
        strDate += "0" + Day + "日";
    }
    switch (date.getDay()) {
        case 0: week = "日"; break; ;
        case 1: week = "月"; break; ;
        case 2: week = "火"; break; ; 
        case 3: week = "水"; break; ;
        case 4: week = "木"; break; ;
        case 5: week = "金"; break; ;
        case 6: week = "土"; break; ; 
    }
    strDate += "(" + week  + ")";
    
    return strDate; 
}

//
//xxxx/xx/xxに変更
//
function FormatyyyyMMdd(date) {
    var Year = 0;
    var Month = 0;
    var Day = 0;
    var week = "";
    var date = new Date(date);
    var strDate = "";
    Year = date.getFullYear();
    Month = date.getMonth()+1;
    Day = date.getDate();
    
    return Year + "/" + Month + "/" + Day;
}